﻿using Basic.FlowRemoteModel.FlowApp;
using Basic.FlowRemoteModel.FlowApp.Model;
using Basic.FlowService.Interface;
using WeDonekRpc.Client;
using WeDonekRpc.Client.Interface;

namespace Basic.FlowService.RpcEvent
{
    internal class FlowAppEvent : IRpcApiService
    {
        private readonly IFlowAppService _Service;

        public FlowAppEvent ( IFlowAppService service )
        {
            this._Service = service;
        }
        public void DeleteFlowApp(DeleteFlowApp obj)
        {
            _Service.Delete(obj.Id);
        }
        public bool SetAppSettleForm ( SetAppSettleForm obj )
        {
            return this._Service.SetSettleFormId(obj.AppId, obj.FormId);
        }
        public FlowAppDatum[] GetAppList ( GetAppList obj )
        {
            return this._Service.GetAppList(obj.AppType);
        }
        public long AddFlowApp ( AddFlowApp data )
        {
            return this._Service.Add(data.Datum);
        }
        public bool SetFlowApp ( SetFlowApp obj )
        {
            return this._Service.Set(obj.Id, obj.Datum);
        }
        public bool EnableFlowApp ( EnableFlowApp obj )
        {
            return this._Service.Enable(obj.Id);
        }

        public FlowAppBase GetFlowApp ( GetFlowApp obj )
        {
            return this._Service.Get(obj.Id);
        }

        public PagingResult<FlowAppData> QueryFlowApp ( QueryFlowApp obj )
        {
            return this._Service.Query(obj.Query, obj.ToBasicPage());
        }

        public bool SetAppFlow ( SetAppFlow set )
        {
            return this._Service.SetFlow(set.Id, set.Data);
        }

        public bool StopFlowApp ( StopFlowApp obj )
        {
            return this._Service.Stop(obj.Id);
        }
    }
}
